import os

import yaml

#写入数据
def write_yaml(filename,data):
    with open(os.getcwd()+"\\data\\"+filename,mode="a+",encoding="utf-8") as f :
        yaml.safe_dump(data,stream=f)

#加载数据 只加载key对应的数据
def load_yaml(filename,key):
    with open(os.getcwd()+"\\data\\"+filename,mode="r",encoding="utf-8") as f:
        data = yaml.safe_load(f)
        return data[key]

#清空yaml文件
def clear_yaml(filename) :
    with open(os.getcwd()+"\\data\\"+filename,mode="r",encoding="utf-8") as f :
        f.truncate()
